import React,{Component} from 'react';
import { Form,Button,Modal} from 'antd';
import SearchType from './FormData'
const FormItem = Form.Item;
//Model类型的检索框

class ModelSearchForm extends Component{
    constructor(props){
        super(props);
    }
    _handleSearch = (e) =>{
        e.preventDefault();
        this.props.form.validateFields((err, values) => {
            console.log(values);
        });
    }
    render(){
        const {column} = this.props;
        const {getFieldDecorator} = this.props.form;
        const formItemLayout = {
            labelCol: {
                xs: { span: 20 },
                sm: { span: 4 },
            },
            wrapperCol: {
                xs: { span: 20 },
                sm: { span: 16 },
            },
        }
        return(
            <Form
                onSubmit={this._handleSearch}
            >
                <Modal title={this.props.title}
                       visible={this.props.maskVisible}
                       onCancel={this.props.onCancel}
                       onOk={this.props.handleOk}
                       footer={[
                           <Button key="back" onClick={this.props.onCancel}>取消</Button>,
                           <Button key="submit" type="primary" loading={this.props.confirmLoading} onClick={this.props.handleOk}>
                               提交
                           </Button>,
                       ]}
                >
                {
                    column.map((item,index)=>{
                        return(
                            <FormItem lable={item.label} key={'form'+index} {...formItemLayout}>
                                {
                                    getFieldDecorator(item.value,{
                                        rules:item.rules
                                })(
                                    <SearchType data={item} />
                                )}
                            </FormItem>
                        )
                    })
                }
                </Modal>
            </Form>
        )
    }
}
const ModelSearch= Form.create({})(ModelSearchForm);
export default ModelSearch;